<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>用户登录</title>
    <style>
        /* 设置页面样式 */
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background-color: #f4f4f4;
            margin: 0;
        }
 
        .login-container {
            width: 300px;
            padding: 20px;
            background-color: #fff;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
 
        .login-container h2 {
            text-align: center;
            margin-bottom: 20px;
        }
 
        .input-group {
            margin-bottom: 15px;
        }
 
        .input-group label {
            display: block;
            font-weight: bold;
            margin-bottom: 5px;
        }
 
        .input-group input {
            width: 100%;
            padding: 8px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
 
        .button-group {
            text-align: center;
        }
 
        .button-group button {
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
 
        .button-group button:hover {
            background-color: #45a049;
        }
 
        .error-message {
            color: red;
            text-align: center;
            display: none;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <h2>登录</h2>
        <div class="input-group">
            <label for="username">用户名</label>
            <input type="text" id="username" name="username" required>
        </div>
        <div class="input-group">
            <label for="password">密码</label>
            <input type="password" id="password" name="password" required>
        </div>
        <div class="button-group">
            <button onclick="login()">登录</button>
        </div>
        <div class="error-message" id="error-message">用户名或密码错误！</div>
    </div>
 
    <script>
        // 模拟登录逻辑
        function login() {
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;
 
            // 简单的验证示例
            const validUsername = 'admin';
            const validPassword = '123456';
 
            if (username === validUsername && password === validPassword) {
                alert('登录成功！');
                // 在此处处理登录成功的逻辑，例如跳转到另一个页面
            } else {
                // 显示错误消息
                const errorMessage = document.getElementById('error-message');
                errorMessage.style.display = 'block';
            }
        }
    </script>
</body>
</html>